package com.nd.mobile.study.domain;

import java.io.Serializable;
import java.lang.reflect.Type;
import java.util.List;

import android.os.Bundle;

import com.fuckhtc.gson.Gson;
import com.fuckhtc.gson.annotations.SerializedName;
import com.fuckhtc.gson.reflect.TypeToken;
import com.nd.mobile.study.common.config.Commands;
import com.nd.mobile.study.common.config.ReqParam;
import com.nd.mobile.study.common.util.HttpRequestUtil;

public class News implements Serializable{

	private static final long	serialVersionUID	= 1L;

	@SerializedName("InfoID")
	private String id;
	
	@SerializedName("InfoTitle")
	private String title;
	
	@SerializedName("InfoViceTitle")
	private String subtitle;
	
	@SerializedName("TitlePicUrl")
	private String titlePicURL;
	
	@SerializedName("InfoDate")
	private String date;
	
	public String getId() {
		return id;
	}

	public String getTitle() {
		return title;
	}

	public String getSubtitle() {
		return subtitle;
	}

	public String getTitlePicURL() {
		return titlePicURL;
	}

	public String getDate() {
		return date;
	}

	public Result<NewsDetail> getDetail() throws Exception {
		Bundle data = new Bundle();
		data.putString(ReqParam.NEWS_ID, id);
		String jsonData = HttpRequestUtil.get(Commands.GET_NEWS_DETAIL, data);
		Gson gson = new Gson();
		Type type = new TypeToken<Result<NewsDetail[]>>(){}.getType();
		Result<NewsDetail[]> detail = gson.fromJson(jsonData, type);
		return new Result<NewsDetail>(detail.getBody()[0], detail.getPrompt());
	}

}
